package ltd.dujiabao.eduoss.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import ltd.dujiabao.commonutils.Result;
import ltd.dujiabao.eduoss.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author : DuJiabao
 * @Project : online-course-project
 * @Time : 2021/4/20 19:48
 * @Desc :
 */
@Api(value = "oss存储")
@RestController
@RequestMapping("/eduoss/file")
@CrossOrigin
public class FileController {
  @Autowired
  FileService fileService;

  @ApiOperation("上传文件")
  @PostMapping("/upload")
  public Result upload(@ApiParam("被上传的文件") MultipartFile file) {
    String url = fileService.upload(file);
    return Result.success().addData("url", url);
  }

}
